/**
 * Created by PC on 2016/1/18.
 */
class TestView extends BaseView {

    public constructor(){
        super();

    }

    public onInitialize():void {
        this.initBg();
        this.initView();
    }

    private initView():void {

        var btn1 = new MButton(180,60,"Socket连接",this.connect,this);
        btn1.x = 240;
        btn1.y = 300;
        this.addChild(btn1);

    }

    private connect():void {
        this.log("connecting...");

        App.pomelo.init(this.onConnected,this);

    }


    private onConnected(respones:any):void {
        this.log(respones);
    }

    private log(str:string):void {
        console.log(str);
    }

    private initBg():void {
        var currStageW: number = StageUtils.getInstance().width;
        var currStageH: number = StageUtils.getInstance().height;
        var darkSprite = new egret.Sprite();
        darkSprite.graphics.clear();
        darkSprite.graphics.beginFill(0x000000,0.3);
        darkSprite.graphics.drawRect(0,0,currStageW,currStageH);
        darkSprite.graphics.endFill();
        darkSprite.width = currStageW;
        darkSprite.height = currStageH;
        this.addChild(darkSprite);
        darkSprite.touchEnabled = true;
    }

}